package com.bbg.amyam.domain.model;

import com.bbg.amyam.domain.enumtype.SyllabusStatus;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord(finders = { "findCoursesByTeacher", "findCoursesBySchoolAcademicPeriod", "findCoursesBySyllabusReviewer" })
public class Course {

    @NotNull
    @ManyToOne
    private SchoolAcdemicPeriod schoolAcademicPeriod;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Program program;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Employee teacher;

    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "S-")
    private Date syllabusDueDate;

    @NotNull
    @ManyToOne
    private Employee syllabusReviewer;

    @NotNull
    @Enumerated(EnumType.STRING)
    private SyllabusStatus syllabusStatus;

    @NotNull
    private Integer maxCapacity;

    @NotNull
    @DecimalMin("0.00")
    @DecimalMax("99999.99")
    @Digits(integer = 5, fraction = 2)
    private BigDecimal tuition;
}
